$(function () {
    $("#jqGrid").Grid({
        url: '../moduletimesrecord/list',
        multiselect: false,
        colModel: [
            {label: '模具号', name: 'moduleNo', index: 'MODULE_NO', width: 80},
            {label: '模次', name: 'times', index: 'TIMES', width: 80},
            {label: '日期', name: 'collectDate', index: 'COLLECT_DATE', width: 80,
                formatter:function (value) {
                    return transDate(value,'yyyy-MM-dd')
                }
            },
            {label: '采集时间', name: 'gmtCreate', index: 'GMT_CREATE', width: 80,
                formatter:function (value) {
                    return transDate(value,'yyyy-MM-dd hh:mm:ss')
                }
            },
            {label: 'id', name: 'id', index: 'ID', key: true, hidden: true},
        ]
    });
});

let vm = new Vue({
    el: '#rrapp',
    data: {
        q: {
            moduleNo: '',
            collectDate: '' // 采集日期
        }
    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function (event) {
            var param = {};
            if(this.q.moduleNo){
                param.moduleNo = this.q.moduleNo;
            }
            if(this.q.collectDate){
                param.collectDate = gmt2DateStr(this.q.collectDate);
            }
            // 清空postData缓存数据
            var postData = $("#jqGrid").jqGrid("getGridParam", "postData");
            $.each(postData, function (k, v) {
                delete postData[k];
            });
            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: param,
                page: page
            }).trigger("reloadGrid");
        },
        reloadSearch: function () {
            vm.q = {
                moduleNo: '',
                collectDate: '' // 采集日期
            };
            vm.reload();
        }
    }
});